// SimpleProperty.cpp : Defines the entry point for the console application.
//

#define _WIN32_WINNT 0x0601

#include <iostream>

#include <tisudshl.h>

using namespace DShowLib;

static void    test_function( Grabber& grabber )
{
    tIVCDPropertyItemsPtr items = grabber.getAvailableVCDProperties();
    if( items == NULL )
    {
        std::cerr << "Device has no properties!!" << std::endl;
        return;
    }

    //<<dumpExposure

    tIVCDPropertyItemPtr exposure = grabber.getVCDPropertyItem( VCDID_Exposure );
    if( exposure == NULL )
    {
        std::cout << "Exposure property not available" << std::endl;
        return;
    }

    tIVCDSwitchPropertyPtr exposure_auto = grabber.getVCDPropertyInterface<IVCDSwitchProperty>( VCDID_Exposure, VCDElement_Auto );
    if( exposure_auto == NULL )
    {
        std::cout << "Exposure property has no auto" << std::endl;
    }
    else
    {
        std::cout << "Exposure auto enabled=" << exposure_auto->getSwitch()  << std::endl;
    }

    tIVCDRangePropertyPtr exposure_range = grabber.getVCDPropertyInterface<IVCDRangeProperty>(VCDID_Exposure, VCDElement_Value );
    if( exposure_range == NULL )
    {
        std::cout << "Exposure property has no range interface" << std::endl;
    }
    else
    {
        std::cout << "Current Exposure range value: " << exposure_range->getValue() << std::endl;

        std::cout << "Exposure range range: [" << exposure_range->getRangeMin() << ".." << exposure_range->getRangeMax() << "]" << std::endl;
    }

	tIVCDAbsoluteValuePropertyPtr exposure_absolute = grabber.getVCDPropertyInterface<IVCDAbsoluteValueProperty>( VCDID_Exposure, VCDElement_Value );
	if( exposure_absolute == NULL )
	{
		std::cout << "Exposure property has no absolute value interface" << std::endl;
	}
	else
	{
		std::cout << "Current Exposure absolute value: " << std::fixed << exposure_absolute->getValue() << " " << exposure_absolute->getDimType() << std::endl;
		std::cout << "Exposure absolute range: [" << exposure_absolute->getRangeMin() << ".." << exposure_absolute->getRangeMax() << "]" << std::endl;
	}
    //>>
}


int     main()
{
    DShowLib::InitLibrary();

	atexit( ExitLibrary );

	Grabber grabber;
	grabber.showDevicePage();

	if( !grabber.isDevValid() )
	{
		std::cerr << "No valid device selected" << std::endl;
	}
	else
	{
        test_function( grabber );
	}

	std::cin.get();

	return 0;
}

